package com.gemini.main.protobuf;

import com.google.common.primitives.UnsignedLong;

public class ProtobufTest {

    private UnsignedLong unsignedLong = UnsignedLong.valueOf(1);


    public static void main(String[] args) {
        /*String binaryString = Long.toBinaryString( Long.MAX_VALUE + 10L);
        UnsignedLong unsignedLong = UnsignedLong.valueOf(binaryString, 2);
        System.out.println(unsignedLong.toString());

        long lowValue =  (Long.MAX_VALUE + 10L)&Long.MAX_VALUE;
        BigInteger integer = BigInteger.valueOf(lowValue).add(BigInteger.valueOf(Long.MAX_VALUE)).add(BigInteger.valueOf(1));
        System.out.println(integer);


        BigDecimal uint64 = BigDecimal.valueOf(lowValue).add(BigDecimal.valueOf(Long.MAX_VALUE)).add(BigDecimal.valueOf(1));
        System.out.println(uint64);*/

        /*PersonProtobuf.Person.Builder builder = PersonProtobuf.Person.newBuilder();
        builder.setEmail("xiaoxiangzi@email.com");
        builder.setId(1);
        builder.setName("筱灬湘子");
        builder.addPhone(PersonProtobuf.Person.PhoneNumber.newBuilder().setNumber("1001").setType(PersonProtobuf.Person.PhoneType.MOBILE));
        builder.addPhone(PersonProtobuf.Person.PhoneNumber.newBuilder().setNumber("1002").setType(PersonProtobuf.Person.PhoneType.HOME));

        PersonProtobuf.Person person = builder.build();
        byte[] buf = person.toByteArray();
        try {
            PersonProtobuf.Person person2 = PersonProtobuf.Person.parseFrom(buf);
            System.out.println(person2.getName() + ", " + person2.getEmail());

            List<PersonProtobuf.Person.PhoneNumber> lstPhones = person2.getPhoneList();

            for (PersonProtobuf.Person.PhoneNumber phoneNumber : lstPhones) {
                System.out.println(phoneNumber.getNumber());
            }
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
        }

        System.out.println(buf);*/
    }

}
